<?php include_once './application/views/sys_admin/common/header.php';  ?>
<!-- admin_main -->
<?php 
	$borrow_check = array(0=>'未检查',1=>'数据已检查');
?>
<div class="form-inline definewidth m20">
	<h3>标的产品简介</h3>
	<table class="table table-bordered table-hover m10">
		 <tr>
		 <td  class="tableleft">标的名称
		 </td>
		 
	    </br>
	        <td><?php echo $borrow['title'];?></td>
	        
	        <td class="tableleft">产品亮点</td>
	        <td><?php echo $borrow['summary'];?></td>
	     </tr>
	</table>
	   		
	
	<h3>标的产品描述</h3>
	<table class="table table-bordered table-hover m10">
		<tr>
		 	<td class="tableleft">融资金额</td>
		 	<td><?php echo number_format($borrow['account'],2);?></td>
		 	<td class="tableleft">收益利率</td>
		 	<td><?php echo $borrow['apr'];?>%</td>
		 	<td class="tableleft">标的类型</td>
		 	<td><?php echo $borrow_type[$borrow['ftype']];?></td>
		</tr>
		<tr>
		 	<td class="tableleft"> 标的状态</td>
		 	<td><?php echo $borrow_status[$borrow['fstatus']];?></td>
		 	<td class="tableleft">标的期限</td>
		 	<td><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{$borrow['time_limit'].'个月';}?></td>
		 	<td class="tableleft">投资周期</td>
		 	<td><?php echo $borrow['bill_times'];?>天</td>
		</tr>
		<tr>
		 	<td class="tableleft">标的起始时间</td>
		 	<td><?php echo date('Y-m-d H:i',$borrow['bill_starttime']);?></td>
		 	<td class="tableleft">起息时间</td>
		 	<td><?php echo $borrow_work_time[$borrow['work_time']];?></td>
		 	<td class="tableleft">预约发标时间</td>
		 	<td><?php if($borrow['auto_verify_time'] > 0){ echo  date('Y-m-d H:i',$borrow['auto_verify_time']);}else{echo '&nbsp;';}?></td>
		</tr>
		<tr>
		 	<td class="tableleft">还款日</td>
		 	<td><?php if($borrow['each_time'] > 0){  echo date('Y-m-d H:i',$borrow['each_time']);}else{ echo '&nbsp;';}?></td>
		 	<td class="tableleft">还款方式</td>
		 	<td><?php echo $borrow_style[$borrow['style']];?></td>
		 	<td class="tableleft">投资有效期</td>
		 	<td><?php echo $borrow['valid_time'];?>天</td>
		</tr>
		<tr>
		 	<td class="tableleft">最小投标金额</td>
		 	<td><?php echo number_format($borrow['lowest_account'],2);?>元</td>
		 	<td class="tableleft">最大投标金额</td>
		 	<td><?php echo $borrow['most_account']>0 ? number_format($borrow['most_account'],2)."元":"无限制";?></td>
		 	<td class="tableleft">客户奖励</td>
		 	<td><?php if($borrow['award'] > 0){?><?php echo $borrow_award[$borrow['award']];?>：<font><?php echo $borrow['funds'];?><?php }?></td>
		</tr>
		<tr>
		 	<td class="tableleft">标的安全等级</td>
		 	<td>最高级别</td>
		 	<td class="tableleft">自动投标比例</td>
		 	<td><?php echo $borrow['auto_apr'];?>%</td>
		 	<td class="tableleft">借款用户编号</td>
		 	<td><?php echo $borrow['user_id'];?></td>
		</tr>
		<tr>
		 	<td class="tableleft">担保用户编号</td>
		 	<td><?php echo $borrow['loan_userid'];?> </td>
		 	<td class="tableleft">逾期日利率</td>
		 	<td><?php echo $borrow['late_apr'];?></td>
		 	<td class="tableleft">可逾期天数</td>
		 	<td><?php echo $borrow['late_days'];?>天</td>
		</tr>
		<tr>
		 	<td class="tableleft">应还总额</td>
		 	<td><?php echo $borrow['repayment_account'];?>元 </td>
		 	<td class="tableleft">已投资金额</td>
		 	<td> <?php echo $borrow['account_yes'];?>元</td>
		 	<td class="tableleft">还需投标金额</td>
		 	<td><?php echo $borrow['account']-$borrow['account_yes'];?>元 </td>
		</tr>
		<tr>
		 	<td class="tableleft">T+N 还款天数</td>
		 	<td> <?php echo $borrow['delay_repay'];?> 天</td>
		 	<td class="tableleft">数据是否检查</td>
		 	<td><?php echo $borrow_verify[$borrow['is_verify']];?>&nbsp;&nbsp;<?php echo $borrow_check[$borrow['is_check']];?></td>
		 	<td class="tableleft">满标审核时间</td>
		 	<td> <?php if($borrow['repayment_time'] > 0){ echo date('Y-m-d H:i', $borrow['repayment_time']);}else{ echo '&nbsp;';}?></td>
		</tr>
	</table>
	
	<h3>投标记录</h3>
	<table class="table table-bordered table-hover definewidth m10">
			 <thead>
			    <tr>
			         <th>投资人/关系</th>
                     <th>当前年利率</th>
                     <th>投标金额</th>
                     <th>有效金额</th>
                     <th>投标时间</th>
					 <th>状态</th>
					 <th>操作</th>
			    </tr>
			</thead>
			<?php foreach($borrow_tender_list as $borrow_tender){ ?>
             <tr>
	             <td><a href="javascript:;" onclick="showUser(<?php echo $borrow_tender['user_id'];?>);"><?php echo $borrow_tender['realname'];?></a></div></td>
                 <td><?php echo $borrow['apr'];?>%</td>
                 <td><?php echo number_format($borrow_tender['money'],2);?>元</td>
                 <td><?php echo number_format($borrow_tender['account'],2);?>元</td>
                 <td><?php echo date('m-d H:i',$borrow_tender['add_time']);?></td>
				 <td>
				  	<?php if(($borrow_tender['money'] == $borrow_tender['account']) && $borrow_tender['fstatus'] != 3){?>
				  		<font>全部通过</font>
				  	<?php }else if($borrow_tender['fstatus'] == 3){?>
				  			已撤回
				  	<?php }else{?>
				  		部分通过
				  	<?php }?>
				  	</div>
				  </td>
				  <td>
			  		<?php if($borrow['fstatus'] != 3 && $borrow_tender['fstatus']!=3 && $borrow['work_time']==2){?>
			  			<a href="javascript:if(confirm('你确定撤回？')){withdraw_the_tender(<?php echo $borrow_tender['id'];?>);}">撤标</a>
			  		<?php }else{?> ---<?php }?>
				  </td>
				</tr>
             <?php }?>
	</table>
	
	<h3>背景调查审核</h3>
	<?php if($list){?>
			<?php foreach($list as $val){?>
				<h4><?php echo $borrow_fsubject[$val['id']];?></h4>
				<img width="60px" height="60px" src="<?php echo CONSET_SUBJECT_IMG.$val['pic']?>"/></br> 
				审核资料有效期：<?php echo $val['valid'];?>个月</br> 
				资料提交说明：<?php echo $val['content'];?></br> 
		<?php }?>
       <?php }else{?>
               	暂无数据
        <?php }?>				
	<hr></br>
	
	<h3>标的安全性审核</h3>
	<table class="table table-bordered table-hover m10">

		<?php if($borrow['ftype'] == 1){?>
		<tr>
		 	<td class="tableleft">真伪鉴定</td>
		 	<td><?php echo $borrow['bill_identification'];?></td>
		 	<td class="tableleft">鉴定单位</td>
		 	<td><?php echo $borrow['bill_unit'];?></td>
		 	<td class="tableleft">完好性</td>
		 	<td><?php echo $borrow_good[$borrow['bill_good']];?></td>
		 	<td class="tableleft">字体清晰度</td>
		 	<td><?php echo $borrow['bill_clarity'];?></td>
		 	<td class="tableleft">用章合规性</td>
		 	<td><?php echo $borrow['bill_compliance'];?></td>
		</tr>
		<tr>
		 	<td class="tableleft">担保方</td>
		 	<td><?php echo $borrow['bill_guarantor'];?></td>
		 	<td class="tableleft">承兑银行</td>
		 	<td><?php echo $borrow_bill_bank[$borrow['bill_bank']];?></td>
		 	<td class="tableleft">资金用途</td>
		 	<td><?php echo $borrow['fuse'];?></td>
		 	<td class="tableleft">保障方式</td>
		 	<td><?php echo $borrow['security_mode'];?></td>
		 	<td class="tableleft">评审留言</td>
			<td><?php echo $borrow['verify_remark'];?></td>
		</tr>
		<tr>
		 <td class="tableleft">质押借款协议</td>
		 <td colspan="4" ><img style="width:200px; height:200px;"  src="/<?php echo $borrow['bill_protocol'];?>"/></td>
		 <td class="tableleft">质扫描件</td>
		 <td colspan="4" ><img style="width:200px; height:200px;"  src="/<?php echo $borrow['bill_edition'];?>"/></td>
		</tr>

		<?php }elseif ($borrow['ftype'] == 2){?>
		<tr>
		 	<td class="tableleft">借款人信息</td>
		 	<td><?php echo $borrow['bill_identification'];?></td>
		 	<td class="tableleft">借款描述</td>
		 	<td><?php echo $borrow['bill_unit'];?></td>
		 	<td class="tableleft">还款来源</td>
		 	<td><?php echo $borrow['bill_clarity'];?></td>
		 	<td class="tableleft">抵押详情</td>
		 	<td><?php echo $borrow['security_mode'];?></td>
		 	<td class="tableleft">产品亮点</td>
		 	<td><?php echo $borrow['summary'];?></td>
		</tr>
		<?php }elseif ($borrow['ftype'] == 3){?>
		<tr>
		 	<td class="tableleft">借款人信息</td>
		 	<td><?php echo $borrow['bill_identification'];?></td>
		 	<td class="tableleft">借款描述</td>
		 	<td><?php echo $borrow['bill_unit'];?></td>
		 	<td class="tableleft">还款来源</td>
		 	<td><?php echo $borrow['bill_clarity'];?></td>
		 	<td class="tableleft">抵押详情</td>
		 	<td><?php echo $borrow['security_mode'];?></td>
		 	<td class="tableleft">产品亮点</td>
		 	<td><?php echo $borrow['summary'];?></td>
		</tr>
		<?php }?>
	</table>
</div>

<div id="userdialog" style="display:none">
	<div id="view_response"></div>
</div>


<script type="text/javascript">
function withdraw_the_tender(borrow_id){
	$.ajax({
		type: "get",
		url: "/sys_admin/borrow/borrow_single/"+borrow_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("撤标成功！");
				$("#chebiao_"+borrow_id).hide();
			}else{
				$("#msg").html("撤标失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
				window.location.reload();
			},3000);
		},
		dataType: "text"
	});
}



function showFsubject(id){
	$.ajax({
		type: "POST",
		url: "/sys_admin/conset/view_subject",
		data: "id="+id,
		success: function(ret){
				$('#userdialog').dialog({
					width:650,
					height:600,
					title:'背景调查审核详细信息',
					buttons:{"关闭":function(){$(this).dialog("close");}},
				}); 
				$("#view_response").html(ret);
			
		},
		dataType: "text"
	});
	
}
</script>
<div id="dialog" title="系统提示" style="display:none">
	<p id="msg" style="text-align:center"></p>
</div>
